<template>
	<view class="index-content">
		<workbench ref="workbench" v-if="pageFlag == 'workbench'"></workbench>
		<inventorySearch v-else-if="pageFlag == 'inventorySearch'"></inventorySearch>
		<dataBoard v-else-if="pageFlag == 'dataBoard'"></dataBoard>
		<my v-else-if="pageFlag == 'my'"></my>
		<tabar :name="pageFlag" @changtab="changtab()"></tabar>
	</view>
</template>
<script>
	import tabar from '@/components/tabBarVue.vue'
	import my from '../my/my.vue'
	import inventorySearch from '../inventorySearch/inventorySearch.vue'
	import workbench from '../workbench/workbench.vue'
	import dataBoard from '../dataBoard/dataBoard.vue'
	export default {
		data() {
			return {
				pageFlag: 'workbench'
			}
		},
		watch: {
			'$store.state.pageFlag'(val, old) {
				this.pageFlag = val
			}
		},
		methods: {
			changtab(name) {
				// this.pageFlag = name
			},

		},
		onShow() {
			// this.$refs.workbench.putInAndOutAndWarning()
		},
		onLoad(options) {
			let userInfo = uni.getStorageSync('userInfo')
			let token = userInfo.token
			if (!token) {
				uni.reLaunch({
					url: '/pages/login/login'
				})
			}
		},
		components: {
			tabar,
			my,
			inventorySearch,
			workbench,
			dataBoard
		}
	}
</script>

<style lang="scss">
	.index-content {
		height: 100vh;
		background-color: #f3f4f6;
	}
</style>